/*
package com.xiaoma.util;

import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.springframework.stereotype.Controller;

*/
/**
 * @author maj
 * @ClassName Test
 * @Description
 * @date 2020-10-13 10:41
 *//*

public class Test {

  public static void main(String[] args) {
    String pkgName = "com.demo.controller";
    String pkgPath = AnnotationScannerUtils.getPkgPath(pkgName);

    // 查找包含RestController和Controller注解的类
    Map<Class<? extends Annotation>, Set<Class<?>>> classesMap = AnnotationScannerUtils.scanClassesByAnnotations(pkgName,
        pkgPath, true,
        Arrays.asList(RestController.class, Controller.class));
    if (classesMap.size() == 0) {
      return;
    }

    Set<Class<?>> classSet = new HashSet<>();
    classesMap.forEach((k, v) -> {
      classSet.addAll(v);
    });

    // 查找包含GetMapping和PostMapping注解的Method
    Map<Class<? extends Annotation>, Set<Method>> methodMap = scanMethodsByAnnotations(classSet,
        Arrays
            .asList(GetMapping.class, PostMapping.class));
    if (methodMap.size() == 0) {
      logger.error("Not exists any method with the specified annotation");
      return;
    }

    methodMap.forEach((k, v) -> {
      StringBuilder sb = new StringBuilder();
      v.forEach(method -> sb.append(method.getName() + ", "));
      logger.info(k.getSimpleName() + ": " + sb.toString());
    });
  }

}
*/
